
#ifndef __I2C_TSC2007_H__
#define __I2C_TSC2007_H__



#include "fsl_common.h"
#include "fsl_iomuxc.h"
#include "pin_mux.h"
#include "clock_config.h"


#define TSC2007Add  0x48U     //7bit

#define TSC2007_PEN_IRQ_GPIO GPIO1
#define TSC2007_PEN_IRQ_GPIO_PIN  (11u)

#define TSC2007_PEN_IRQ           GPIO1_Combined_0_15_IRQn
#define TSC2007_PEN_IRQHandler    GPIO1_Combined_0_15_IRQHandler




#define  PRESURE_PARAMETER         1U  //����ѹ��ֵ�Ĳ���  x_plate_ohms/4096


#define POINT0_PHY_X   20
#define POINT0_PHY_Y   15

#define POINT1_PHY_X   440
#define POINT1_PHY_Y   15

#define POINT2_PHY_X   440
#define POINT2_PHY_Y   257

#define POINT3_PHY_X   20
#define POINT3_PHY_Y   257





typedef enum TSC2007_CMD_12BIT          //
{
//  SteupCMD = 0xB0U,         /* ��������*/
    Measure_X = 0xC4U,       /*����X_position */
    Measure_Y = 0xD4U,      /*����Y_position  */
    Measure_Z1 = 0xE4U,     /*����Z1_position */
    Measure_Z2 = 0XF4U    /*����Z2_position */
} TSC2007_CMD_12BIT_t;


typedef struct
{
    int  X;
    int  Y;
} POINT;


typedef enum _touch_coor_type
{
    Logic_Coor = 0,    /*�߼�����*/
    Phy_Coor   = 1,      /*�������� */
} touch_coor_type_t;



typedef enum _touch_event
{
    kTouch_Down = 0,    /*!< The state changed to touched. */
    kTouch_Up = 1,      /*!< The state changed to not touched. */
    kTouch_Contact = 2, /*!< There is a continuous touch being detected. */
    kTouch_Reserved = 3 /*!< No touch information available. */
} touch_event_t;


extern volatile bool g_InputSignal;



void delay(uint32_t  Count);




void TSC2007_PEN_IRQHandler(void);
void TSC2007_InitIRQPins(void);
void I2C_TSC2007_Init(void);
status_t  Get_TSC2007_MeasureResult(TSC2007_CMD_12BIT_t   cmd, uint8_t *dataBuff);
void Return_to_PWRDOWN(void);




uint8_t Get_Touch_event(POINT *touch_point,touch_event_t *touch_event,touch_coor_type_t touch_coor_type);
bool Calibration_start(void);
void Get_calibrate_para(uint8_t *buff);
void Set_calibrate_para(uint8_t *buff);

#endif
